<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH. 'controllers/layout.php');

class News extends Layout
{
	public function __construct()
	{
		parent::__construct();
	}
	
	public function index()
	{
		$config['per_page'] = 5;
		if($this->input->post('search')){
			$search = $this->input->post('search');
			$page = 0;
		}else{
			$search = $this->input->get('search');
		}
		$page = $this->uri->segment(2);
	
		$search = 15;
		$result = $this->product_model->getAllSearchDichvu($search, $page, $config['per_page']);

		$this->load->library('pagination');
		
		$config['base_url'] = base_url().'/tin-tuc';
		$config['total_rows'] = $result['total_record'];
		
		
		$config['use_page_numbers'] = false;
		$config['uri_segment'] = 2;
		$config['num_links'] = 1;
		$this->pagination->initialize($config);
		$data["paging"] = $this->pagination->create_links();
		
		$data['news'] = $result['news'];

        $slider = $this->utility_model->selectSlider('tbl_slider');
		
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
		$this->_data['main_container'] = $this->load->view('frontend/news_view', array(
				'news' => $data['news'],
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
				'pagination' => $data["paging"],
                'silders' => $slider,
		), true);
		$this->load->view('frontend/layout_view', $this->_data);
	}
	
	public function detailview()
	{

        $slider = $this->utility_model->selectSlider('tbl_slider');
		$param = $this->uri->ruri_to_assoc();
		$news = $this->utility_model->getDetail('tbl_content', 'content_id', $param['id']);
		$khoanggia = $this->utility_model->selectStatus('tbl_aboutprice');
		$hangsanxuat = $this->utility_model->selectStatus('tbl_origin');
		$thuonghieu = $this->utility_model->selectStatus('tbl_brand');
		$congxuat = $this->utility_model->selectStatus('tbl_capacity');
		$this->_data['main_container'] = $this->load->view('frontend/newdetail_view', array(
				'news' => $news,
				'khoanggia' => $khoanggia,
				'thuonghieu' => $thuonghieu,
				'hangsanxuat' => $hangsanxuat,
				'congxuat' => $congxuat,
                'silders' => $slider,
		), true);
		$this->load->view('frontend/layout_view', $this->_data);
	}
	
	
	

	
}